package com.sakuracard.stepdemo.util.json.adapter;

import com.google.gson.*;
import com.sakuracard.stepdemo.model.base.TransferableBaseEntity;

import java.lang.reflect.Type;

public class TransferableBaseEntityAdapter
    implements JsonSerializer<TransferableBaseEntity>,
    JsonDeserializer<TransferableBaseEntity> {

  @Override
  public TransferableBaseEntity deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
    return null;
  }

  @Override
  public JsonElement serialize(TransferableBaseEntity transferableBaseEntity, Type type, JsonSerializationContext jsonSerializationContext) {
    try {
      return jsonSerializationContext.serialize(transferableBaseEntity.serializeEntity());
    } catch (Exception e) {
      e.printStackTrace(System.err);
    }
    return null;
  }
}
